import React from 'react'
import {
  MinusOutlined,
  FullscreenOutlined,
  CloseOutlined,
} from '@ant-design/icons'
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'
import styles from './index.module.less'

// 404页面
export default function NotFound() {
  return (
    <>
      {/* 头部 */}
      {!qiankunWindow.__POWERED_BY_QIANKUN__ ? <Header /> : ''}

      <div className={styles.container}>
        <div>404 资源未找到或者未加载资源，请从主程序界面重新加载资源</div>
      </div>
    </>
  )
}

//
// 头部部分
function Header() {
  // 窗口最小化
  const minWindow = () => (window as any).readingWindow.minWindow()
  // 窗口最大化切换
  const maxWindow = () => (window as any).readingWindow.maxWindow()
  // 关闭窗口
  const closeWindow = () => (window as any).readingWindow.closeWindow()

  return (
    <div className={styles.headerContainer}>
      <div className={styles.label}>404 NotFound</div>

      <div className={styles.controlBtns}>
        <MinusOutlined style={{ fontSize: '20px' }} onClick={minWindow} />
        <FullscreenOutlined style={{ fontSize: '20px' }} onClick={maxWindow} />
        <CloseOutlined style={{ fontSize: '20px' }} onClick={closeWindow} />
      </div>
    </div>
  )
}
